/*
Along with any other imports put this line: 

    import csa.CSATester;

First: from your main you will call the following function in CSATester:
    public static boolean Test1(int[])
    Returns: true if tests have been passed, false otherwise
    int[]: an array of integers indicating which tests to run. Here are the values
        1: oddsAreMore
        2: countInRange
        3: countOf
        4: reverse
        5: sortStatus
        6: randomOrder
        7: marchingOrder
        8. replaceNegatives
        9. removeNegatives

If the array param is empty , no tests are run. 
Example: if you wanted to test only marchingOrder() and reverse(), you 
would
    int[] testThese ] {7, 3};
    CSATester.Test1(testThese);

Once you import csa.CSATester you will have to 'stub' all of the functions described for the assignment; 'to stub' means to declare the function but leave the implementation out for now. Here is a way to do that

    char[] reverse(char[] input) // I'm not ready to code reverse yet
        {
        DebugLog.Log("Ooops.... reverse() is not ready yet.");
        return null; // null is like 0 for arrays
        }




*/


package csa;

import general.DebugLog;

public class CSATester
    {
    public static boolean Test1(int[] selections)
        {
        DebugLog.Log("Sorry, but the test routine has not been written yet.");
        DebugLog.Log("Thank you for calling, " +
            "and please try your call again later.");
        return true;

        StringBuffer record = new StringBuffer("Testing ArrayPrac - Begin" + "\r\n");
        byte tested = 0;
        int totalErrs = 0;
        int testsFailed = 0;
        for (int i = 0; i < selections.length; i++)
            {
            switch (selections[i])
                {
                case 0:
                    record.append("Unrecognized test label: " + i);
                    break;
                case 1:
                    totalErrs += 
                        ArrPracoddsAreMore(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 2:
                    totalErrs += 
                        ArrPraccountInRange(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 3:
                    totalErrs += 
                        ArrPraccountOf(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 4:
                    totalErrs += 
                    ArrPracreverse(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 5:
                    totalErrs += 
                    ArrPracsortStatus(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 6:
                    totalErrs += 
                    ArrPracrandomOrder(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 7:
                    totalErrs += 
                    ArrPracmarchingOrder(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 8:
                    totalErrs += 
                    ArrPracreplaceNegatives(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                case 9:
                    totalErrs += 
                    ArrPracremoveNegatives(record);
                    tested++;
                    if (totalErrs > save)
                        testsFailed++;            
                    break;
                default:
                    record.append("Unrecognized test label: " + i);
                } // switch
            }
         record.append("\r\n" + "Ran " + tested + " tests");
         record.append("\r\n" + "of these " + testsFailed + " did not pass.");
         record.append("\r\n" + "Total number of errors was " + totalErrs + 
         record.append("\r\n");
        System.out.print(record);
        }
    public static boolean Test2(int[] selections)
        {
        return Test1(selections);
        }
    public static boolean Test3(int[] selections)
        {
        return Test1(selections);
        }
    public static boolean Test4(int[] selections)
        {
        return Test1(selections);
        }

    public static int ArrPracoddsAreMore(StringBuffer record)
        {
        record.append("Report on OddsAreMore" + "\r\n");
        int err = 0;
        // oddsAreMore
        int[] t1 = {3, 5, 3, 1, 8, 2};
        if (!ArrayPracA.oddsAreMore(t1))
            {
            err++;
            record.append("   " + t1.toString() + "\r\n");
            }
        int temp = t1[0];
        t1[0] = t1[tl.length - 1];
        t1[tl.length - 1] = t1[0];
        if (!ArrayPracA.oddsAreMore(t1))
            {
            err++;
            record.append("   " + t1.toString() + "\r\n");
            }
        for (int i = 0; i < t1.length; i++)
            {
            t1[i]++;
            }
        if (ArrayPracA.oddsAreMore(t1))
            {
            err++;
            record.append("   " + t1.toString() + "\r\n");
            }
        boolean save = oddsAreMore(t1);
        for (int i = 0; i < t1.length; i++)
            {
            if (t1[i] % 2 == 1)
                t1[i] = - t1[i];
            }
        if (ArrayPracA.oddsAreMore(t1) == save)
            {
            err++;
            record.append("   " + t1.toString() + "\r\n");
            }
        int[] t2 = {1, 2, 1, -14, -15, 1, 32, 31, -2, 0, 8, 7};
        if (ArrayPracA.oddsAreMore(t2))
            {
            err++;
            record.append("   " + t2.toString() + "\r\n");
            }
        record.append("tests not passed: " + err + "\r\n" + "\r\n");
        return err;
        }
    public static int ArrPraccountInRange(StringBuffer record)
        {
        int err = 0;
        record.append("Report on countInRange" + "\r\n");
        int[] t1 = {1, 2, 1, -14, -15, 1, 32, 31, -2, 0, 8, 7};
        int c = ArrayPracA.countInRange(-1000, -1);
        if (c != 3)
            {
            err++;
            record.append("   " + t1.toString() + " negative nums \r\n");
            }
        c = ArrayPracA.countInRange(0, 1000);
        if (c != 9)
            {
            err++;
            record.append("   " + t1.toString() + " non-negative nums \r\n");
            }
        c = ArrayPracA.countInRange(1, 1);
        if (c != 3)
            {
            err++;
            record.append("   " + t1.toString() + " one \r\n");
            }
        c = ArrayPracA.countInRange(-15, -15);
        if (c != 1)
            {
            err++;
            record.append("   " + t1.toString() + " -15 \r\n");
            }
        c = ArrayPracA.countInRange(13, 13);
        if (c != 0)
            {
            err++;
            record.append("   " + t1.toString() + " 13 \r\n");
            }

        int[] t2 = {111};
        c = ArrayPracA.countInRange(-200, 311);
        if (c != 1)
            {
            err++;
            record.append("   " + t2.toString() + " [-200, 311] \r\n");
            }
        c = ArrayPracA.countInRange(111, 111);
        if (c != 1)
            {
            err++;
            record.append("   " + t2.toString() + " [111, 111] \r\n");
            }
        c = ArrayPracA.countInRange(-111, -112);
        if (c != 0)
            {
            err++;
            record.append("   " + t2.toString() + " [-111, -112] \r\n");
            }
        record += "tests not passed: " + err + "\r\n" + "\r\n";
        return err;
        }
    public static int ArrPracreverse(StringBuffer record)
        {
        int err = 0;
        record.append("Report on reverse" + "\r\n");
        String str1 = "RadaR";
        char[] ptr = str1.toCharArray();
        ptr = ArrayPracA.reverse(ptr);
        String str2 = ptr;
        if (str2.reverse() != str1)
            {
            err++;
            record.append("   " + str1 + "\r\n");
            }
        str1 = "aBcDeFgHiJkLmNoPqRsTuVwXyZ12345";
        ptr = str1.toCharArray();
        ptr = ArrayPracA.reverse(ptr);
        str2 = ptr;
        if (str2.reverse() != str1)
            {
            err++;
            record.append("   " + str1 + "\r\n");
            }
        str1 = "57";
        ptr = str1.toCharArray();
        ptr = ArrayPracA.reverse(ptr);
        str2 = ptr;
        if (str2.reverse() != str1)
            {
            err++;
            record.append("   " + str1 + "\r\n");
            }
        str1 = "z";
        ptr = str1.toCharArray();
        ptr = ArrayPracA.reverse(ptr);
        str2 = ptr;
        if (str2.reverse() != str1)
            {
            err++;
            record.append("   " + str1 + "\r\n");
            }
        str1 = "";
        ptr = str1.toCharArray();
        ptr = ArrayPracA.reverse(ptr);
        str2 = ptr;
        if (str2.reverse() != str1)
            {
            err++;
            record.append("   " + str1 + "(empty string) \r\n");
            }
        record += "tests not passed: " + err + "\r\n" + "\r\n";
        return err;
        }
    public static int ArrPraccountOf(StringBuffer record)
        {
        int err = 0;
        record.append("Report on countOf" + "\r\n");
        str1 = "aBcDeFgHiJkLmNoPqRsTuVwXyZ12345";
        ptr = str1.toCharArray();
        char ltr = 'a';
        int c = ArrayPracA.countOf(ptr, ltr);
        if (c != 1)
            {
            err++;
            record.append("   didn't count" + ltr + " in " + str1 + "\r\n");
            }
        ltr = '5';
        c = ArrayPracA.countOf(ptr, ltr);
        if (c != 1)
            {
            err++;
            record.append("   didn't count" + ltr + " in " + str1 + "\r\n");
            }
        str1 = "aBcDeFgHiJkLmaBaaDDDDDDDDDeFiHedcba";
        ptr = str1.toCharArray();
        ltr = '5';
        c = ArrayPracA.countOf(ptr, ltr);
        if (c != 0)
            {
            err++;
            record.append("   didn't count" + ltr + " in " + str1 + "\r\n");
            }
        ltr = 'D';
        c = ArrayPracA.countOf(ptr, ltr);
        if (c != 10)
            {
            err++;
            record.append("   didn't count" + ltr + " in " + str1 + "\r\n");
            }
        record += "tests not passed: " + err + "\r\n" + "\r\n";
        return err;
        }


    } // class CSATester